package com.platform.api.common.controller;

import com.platform.api.bzproject.model.User;
import com.platform.security.service.UserConnect;
import com.platform.security.util.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

/**
 * @author guoyunfei on 2022/3/4 15:06
 * @className BaseController 基类
 * @description TODO
 * @Version 1.0
 */

public abstract class BaseController {

    @Autowired
    HttpServletRequest request;

    /**
     * 获取当前请求平台的类型
     * @return
     */
    public Integer getSystemType(){
        Integer type = StringUtils.isNotBlank(request.getHeader("systemType")) ? Integer.valueOf(request.getHeader("systemType")) : 0;
        return type;
    }

    /**
     * 获取当前用户ID
     * @return
     */
    public String getUserId(){
        String userId = SecurityUtils.getUser().getUserId();
        return userId;
    }

    /**
     * 获取当前用户信息
     * @return
     */
    public UserConnect getUser(){
        return SecurityUtils.getUser();
    }


}
